package com.dagit.test.network;

import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;

import com.dagit.network.Instance;
import com.dagit.network.traffic.Message;
import com.dagit.network.traffic.RegisterInstanceMessage;

public class Client {
	public static void main(String[] args) throws Exception {
		Socket socket = new Socket("localhost", 8050);
		Message<Instance> msg = new Message<Instance>();
		msg.setInput(new Instance("localhost", 1111));
		msg.setClazz(RegisterInstanceMessage.class.getName());
		ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream());
		out.writeObject(msg);
		ObjectInputStream input = new ObjectInputStream(socket.getInputStream());
		while(input.available() > 0){
			
		}
		Boolean ret = (Boolean)input.readObject();
		System.out.println(ret.booleanValue());
		
		Thread.sleep(10000);
		System.out.println("stopped()");
	}
}
